
//主页轮播图
var hide_Show = document.getElementsByClassName("toggle");
function show(e) {
     hide_Show[e].style.display = 'block';
};
function hide(e) {
     hide_Show[e].style.display = 'none';
};
var carousel_img = document.getElementsByClassName("carousel_img");
var img_Quantity=0;
function showLogin() {
    img_Quantity+=1;
    carousel_img[0].src = "/Web_img/carousel_img"+img_Quantity+".webp";
    if (img_Quantity==3){
        img_Quantity=0;
    }
};
//自动执行
setInterval("showLogin()","5000");

function Operation_Left() {
    //获取轮播图 图片路径
    var img_Numbering = carousel_img[0].src
    //截取后面的数字 然后+1
    var index = Number(img_Numbering.substring(42,43));
    //如果图片等于3则没有图片
    if (index == 3){
        index = 0;
    }
    var img_Url = "/Web_img/carousel_img"+(index+1)+".webp";
    //修改
    carousel_img[0].src = img_Url;
};
created:function background_Continued_S(my){
    my.style.display = 'block';
}
created:function background_Continued_H(my) {
    my.style.display = 'none';
}
created:function img_Src_fff(my,direction){
    if (direction == 'left'){
        var img_Src = my.firstChild;
        img_Src.src = "/Web_img/carousel_left_%23fff.png";
    }else if (direction == 'right'){
        var img_Src = my.firstChild;
        img_Src.src = "/Web_img/carousel_right_%23fff.png";
    }
};
created:function img_Src_000(my,direction){
    if (direction == 'left') {
        var img_Src = my.firstChild;
        img_Src.src = "/Web_img/carousel_left_%23000.png";
    }else if (direction == 'right'){
        var img_Src = my.firstChild;
        img_Src.src = "/Web_img/carousel_right_%23000.png";
    }
};

create:function product_switch(index) {
    let produc = document.getElementsByClassName("produc");
    let this_none = document.getElementsByClassName("control_switch");
    if (index == 1){
        this_none[0].style.color = '#FF6700';
        this_none[1].style.color = '#000';
        produc[1].style.display = 'none';
        produc[2].style.display = 'block';
    }else if (index == 2){
        this_none[1].style.color = '#FF6700';
        this_none[0].style.color = '#000';
        produc[2].style.display = 'none';
        produc[1].style.display = 'block';

        //----------
    }else if (index == 3){
        this_none[3].style.color = '#FF6700';
        this_none[4].style.color = '#000';
        console.log(produc)
        produc[4].style.display = 'none';
        produc[5].style.display = 'block';
    }else if (index == 4){
        this_none[4].style.color = '#FF6700';
        this_none[3].style.color = '#000';
        produc[5].style.display = 'none';
        produc[4].style.display = 'block';


        //----------
    }else if (index == 5){
        this_none[8].style.color = '#000';
        this_none[7].style.color = '#000';
        this_none[6].style.color = '#000';
        this_none[5].style.color = '#FF6700';

        produc[6].style.display = 'none';
        produc[7].style.display = 'none';
        produc[8].style.display = 'none';
        produc[9].style.display = 'block';

    }else if (index == 6){
        this_none[8].style.color = '#000';
        this_none[7].style.color = '#000';
        this_none[6].style.color = '#FF6700';
        this_none[5].style.color = '#000';

        produc[6].style.display = 'none';
        produc[7].style.display = 'none';
        produc[8].style.display = 'block';
        produc[9].style.display = 'none';
    }else if (index == 7){
        this_none[8].style.color = '#000';
        this_none[7].style.color = '#FF6700';
        this_none[6].style.color = '#000';
        this_none[5].style.color = '#000';

        produc[6].style.display = 'none';
        produc[7].style.display = 'block';
        produc[8].style.display = 'none';
        produc[9].style.display = 'none';
    }else if (index == 8){
        this_none[8].style.color = '#FF6700';
        this_none[7].style.color = '#000';
        this_none[6].style.color = '#000';
        this_none[5].style.color = '#000';

        produc[6].style.display = 'block';
        produc[7].style.display = 'none';
        produc[8].style.display = 'none';
        produc[9].style.display = 'none';

        //----------
    }else if (index == 9){
        this_none[9].style.color = '#FF6700';
        this_none[10].style.color = '#000';
        this_none[11].style.color = '#000';
        this_none[12].style.color = '#000';

        produc[10].style.display = 'none';
        produc[11].style.display = 'none';
        produc[12].style.display = 'none';
        produc[13].style.display = 'block';
    }else if(index == 10){
        this_none[9].style.color = '#000';
        this_none[10].style.color = '#FF6700';
        this_none[11].style.color = '#000';
        this_none[12].style.color = '#000';

        produc[10].style.display = 'none';
        produc[11].style.display = 'none';
        produc[12].style.display = 'block';
        produc[13].style.display = 'none';
    }else if(index == 11){
        this_none[9].style.color = '#000';
        this_none[10].style.color = '#000';
        this_none[11].style.color = '#FF6700';
        this_none[12].style.color = '#000';

        produc[10].style.display = 'none';
        produc[11].style.display = 'block';
        produc[12].style.display = 'none';
        produc[13].style.display = 'none';
    }else if(index == 12){
        this_none[9].style.color = '#000';
        this_none[10].style.color = '#000';
        this_none[11].style.color = '#000';
        this_none[12].style.color = '#FF6700';

        produc[10].style.display = 'block';
        produc[11].style.display = 'none';
        produc[12].style.display = 'none';
        produc[13].style.display = 'none';
        //------------
    }else if(index == 13){
        this_none[13].style.color = '#FF6700';
        this_none[14].style.color = '#000';
        this_none[15].style.color = '#000';
        this_none[16].style.color = '#000';

        produc[14].style.display = 'none';
        produc[15].style.display = 'none';
        produc[16].style.display = 'none';
        produc[17].style.display = 'block';
    }else if(index == 14){
        this_none[13].style.color = '#000';
        this_none[14].style.color = '#FF6700';
        this_none[15].style.color = '#000';
        this_none[16].style.color = '#000';

        produc[14].style.display = 'none';
        produc[15].style.display = 'none';
        produc[16].style.display = 'block';
        produc[17].style.display = 'none';
    }else if(index == 15){
        this_none[13].style.color = '#000';
        this_none[14].style.color = '#000';
        this_none[15].style.color = '#FF6700';
        this_none[16].style.color = '#000';

        produc[14].style.display = 'none';
        produc[15].style.display = 'block';
        produc[16].style.display = 'none';
        produc[17].style.display = 'none';
    }else if(index == 16){
        this_none[13].style.color = '#000';
        this_none[14].style.color = '#000';
        this_none[15].style.color = '#000';
        this_none[16].style.color = '#FF6700';

        produc[14].style.display = 'block';
        produc[15].style.display = 'none';
        produc[16].style.display = 'none';
        produc[17].style.display = 'none';
        //---------
    }else if(index == 17){
        this_none[17].style.color = '#FF6700';
        this_none[18].style.color = '#000';
        this_none[19].style.color = '#000';
        this_none[20].style.color = '#000';

        produc[18].style.display = 'none';
        produc[19].style.display = 'none';
        produc[20].style.display = 'none';
        produc[21].style.display = 'block';
    }else if(index == 18){
        this_none[17].style.color = '#000';
        this_none[18].style.color = '#FF6700';
        this_none[19].style.color = '#000';
        this_none[20].style.color = '#000';

        produc[18].style.display = 'none';
        produc[19].style.display = 'none';
        produc[20].style.display = 'block';
        produc[21].style.display = 'none';
    }else if(index == 19){
        this_none[17].style.color = '#000';
        this_none[18].style.color = '#000';
        this_none[19].style.color = '#FF6700';
        this_none[20].style.color = '#000';

        produc[18].style.display = 'none';
        produc[19].style.display = 'block';
        produc[20].style.display = 'none';
        produc[21].style.display = 'none';
    }else if(index == 20){
        this_none[17].style.color = '#000';
        this_none[18].style.color = '#000';
        this_none[19].style.color = '#000';
        this_none[20].style.color = '#FF6700';

        produc[18].style.display = 'block';
        produc[19].style.display = 'none';
        produc[20].style.display = 'none';
        produc[21].style.display = 'none';
        //---------
    }else if (index == 21){
        this_none[21].style.color = '#FF6700';
        this_none[22].style.color = '#000';
        this_none[23].style.color = '#000';
        this_none[24].style.color = '#000';

        produc[22].style.display = 'none';
        produc[23].style.display = 'none';
        produc[24].style.display = 'none';
        produc[25].style.display = 'block';
    }else if (index == 22){
        this_none[21].style.color = '#000';
        this_none[22].style.color = '#FF6700';
        this_none[23].style.color = '#000';
        this_none[24].style.color = '#000';

        produc[22].style.display = 'none';
        produc[23].style.display = 'none';
        produc[24].style.display = 'block';
        produc[25].style.display = 'none';
    }else if (index == 23){
        this_none[21].style.color = '#000';
        this_none[22].style.color = '#000';
        this_none[23].style.color = '#FF6700';
        this_none[24].style.color = '#000';

        produc[22].style.display = 'none';
        produc[23].style.display = 'block';
        produc[24].style.display = 'none';
        produc[25].style.display = 'none';
    }else if (index == 24){
        this_none[21].style.color = '#000';
        this_none[22].style.color = '#000';
        this_none[23].style.color = '#000';
        this_none[24].style.color = '#FF6700';


        produc[22].style.display = 'block';
        produc[23].style.display = 'none';
        produc[24].style.display = 'none';
        produc[25].style.display = 'none';
    }else{
        console.log("无法使用")
    }
}
function Operation_Right() {
    //获取轮播图 图片路径
    var img_Numbering = carousel_img[0].src
    //截取后面的数字 然后+1
    var index = Number(img_Numbering.substring(42,43));
    //如果图片等于0则没有图片赋值4
    if ((index-1) == 0){
        index = 4;
    }
    var img_Url = "/Web_img/carousel_img"+(index-1)+".webp";
    //修改
    carousel_img[0].src = img_Url;
};
$(function () {
    //主页导航栏 显示与隐藏
    var category = $(".category");
    var effect = $(".hidden_Content");
    $(document).ready(function () {
        category.mouseover(function () {
            var index = category.index(this);
            $(effect[index]).stop().slideDown("slow");
        });
        category.mouseout(function () {
            var index = category.index(this);
            $(effect[index]).stop().slideUp("slow");
        });
    });
    $(document).ready(function () {
        effect.mouseover(function () {
            var index = effect.index(this);
            $(effect[index]).stop().slideDown("slow");
        });
        effect.mouseout(function () {
            var index = effect.index(this);
            $(effect[index]).stop().slideUp("slow");
        });
    });
    $(".produc_Information").click(function(){
        var i = $(".produc_Information").index(this);
        var mysqlname = document.getElementsByClassName("mysqlname")
        var url = window.location.href;
        var id = document.getElementsByClassName("id")

        if (url != "http://localhost:8087/Front/page"){
            var useid = url.split(",");
            location.href = "/product/details?id="+id[i].innerText+"&name="+mysqlname[0].innerText+"&userid="+useid[1];
        }else{
            location.href = "/product/details?id="+id[i].innerText+"&name="+mysqlname[0].innerText;
        }
    });
});